var coco_site_id = 3529; var visitor_id; var coco_3_id = ''; var coco_no_tracking = 0; var current_pid = '1D92ADF5AB53204D75C84B9502B4E658'; var coco_3_pid = ''; var data_share_company_pids; var insert_cid; if( coco_3_pid === '' ) { if( 1 < window.location.search.length ){ var query = window.location.search.substring( 1 ); var parameters = query.split( '&' ); for( var kasika_i = 0; kasika_i < parameters.length; kasika_i++ ){ var elements = parameters[kasika_i].split( '=' ); if( elements[0] === 'coco_pid' ){ coco_3_pid = elements[1]; break; } } } } //正常系 if(coco_3_pid === current_pid) { insert_cid = true; }else { //準正常系 if (Array.isArray(data_share_company_pids)) { for (var kasika_i = 0, kasika_len = data_share_company_pids.length; kasika_i < kasika_len; ++kasika_i) { if (coco_3_pid === data_share_company_pids[kasika_i]) { insert_cid = true; } } } } if( insert_cid ) { coco_3_id = ''; } var KASIKA; var cp_page_design_id = 0; var _paq = _paq || []; var _visitor_id; var coco_cid; _paq.push([ function() { visitor_id_send = this.getVisitorId(); _visitor_id = this.getVisitorId(); // キャンペーン場合、ページデザインをトラッキングため if (cp_page_design_id != 0) { this.setCustomVariable(2,'cp_page_design_id',cp_page_design_id,'page'); } if (KASIKA) { var KASIKA_MAIN_DOMAIN = "kasika.io"; if (KASIKA.cro_policies && !document.URL.match(KASIKA_MAIN_DOMAIN)) { KASIKA.init(); } } this.setCustomVariable('1','cookie_visitor_id',visitor_id_send,'page'); }]); _paq.push(["setCookieDomain", ""]); if(!coco_no_tracking) _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//piwik.kasika.io/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', coco_site_id]); _paq.push(["enableHeartBeatTimer", 10]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); coco_cid = GetCookie('_coco_cid'); // -- Update pv-c Mapping _paq.push([ function() { visitor_id = this.getVisitorId(); var cid = GetCookie('_coco_cid'); if( !cid ){ if( insert_cid ) { if (1 < window.location.search.length) { var query = window.location.search.substring(1); var parameters = query.split('&'); for (var kasika_i = 0; kasika_i < parameters.length; kasika_i++) { var elements = parameters[kasika_i].split('='); if (elements[0] === 'coco_cid') { cid = elements[1]; break; } } } } } if( !cid ) { var request = new XMLHttpRequest(); var requestURL = "//panda.kasika.io/get_cid_with_sv.php?sid=" + coco_site_id + "&vid=" + visitor_id; request.open("get", requestURL); request.onload = function (event) { if (request.readyState === 4) { if (request.status === 200) { var data = JSON.parse(request.responseText); //応答が200の場合は戻ってきたcidを入れる if( data.cid !== '' ) { cid = data.cid; console.log( data.cid ); } } else { console.log(request.responseText); } } }; request.onerror = function (event) { console.log(event.type); }; request.send(null); } var that = this var count = 0; var timer = setInterval(function () { if (!cid) { var _coco_cookie = GetCookie('_coco_cid'); cid = _coco_cookie ? _coco_cookie : ''; } if (!visitor_id) { visitor_id = that.getVisitorId(); } if (cid || coco_3_id !== '' || count > 60) { var request = new XMLHttpRequest(); var requestURL = "//panda.kasika.io/update_pv-c.php?cid=" + cid + "&nt=" + coco_no_tracking + "&si=" + coco_site_id + "&vi=" + visitor_id + "&rndid=" + create_privateid(16) + '&3id=' + coco_3_id + '&url=' + encodeURIComponent(location.href); request.open("get", requestURL, true); request.onload = function (event) { if (request.readyState === 4) { if (request.status === 200) { console.log("successfile"); } else { console.log("failfile"); } } }; request.onerror = function (event) { console.log(event.type); }; request.send(null); clearInterval(timer); } count++; }, 500); }]); // -- random id (prevent js file caching) function create_privateid( n ){ var CODE_TABLE = "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; var r = ""; for (var kasika_i = 0, kasika_k = CODE_TABLE.length; kasika_i < n; kasika_i++){ r += CODE_TABLE.charAt(Math.floor(kasika_k * Math.random())); } return r; } function GetCookie( name ) { var result = null; var cookieName = name + '='; var allcookies = document.cookie; var position = allcookies.indexOf( cookieName ); if( position != -1 ) { var startIndex = position + cookieName.length; var endIndex = allcookies.indexOf( ';', startIndex ); if( endIndex == -1 ) { endIndex = allcookies.length; } result = decodeURIComponent( allcookies.substring( startIndex, endIndex ) ); } return result; } function GetCookieByCookieSync( matchCookies ) { if( matchCookies.length > 0 ){ var result = {}; var allCookies = ReadCookies(); for (kasika_i = 0; kasika_i < matchCookies.length; kasika_i++) { var matchCookie = matchCookies[kasika_i]; if (matchCookie['match_type'] == 1) { // 全部一致 if (allCookies[matchCookie['cookie_name']]) { result[matchCookie['cookie_name']] = decodeURIComponent(allCookies[matchCookie['cookie_name']]); } } else if (matchCookie['match_type'] == 2) { // 部分一致 for(var cookieName in allCookies) { if (allCookies.hasOwnProperty(cookieName)) { if (cookieName.indexOf(matchCookie['cookie_name']) !== -1) { var position = decodeURIComponent(allCookies[cookieName]).indexOf('.'); var uid3rdpartyVisitorId; if (position == -1) { uid3rdpartyVisitorId = decodeURIComponent(allCookies[cookieName]).indexOf('.'); } else { uid3rdpartyVisitorId = decodeURIComponent(allCookies[cookieName]).substring(0, position); } result[matchCookie['cookie_name']] = uid3rdpartyVisitorId; } } } } } return encodeURIComponent(JSON.stringify(result)); }else{ return ''; } } function ReadCookies() { var pairs = document.cookie.split(";"); var cookies = {}; for (var kasika_i=0; kasika_i now_datetime || CRO_POLICIES[index].end_date < now_datetime)) { return false; } else if (CRO_POLICIES[index].start_date && !CRO_POLICIES[index].end_date && CRO_POLICIES[index].start_date > now_datetime) { return false; } else if (!CRO_POLICIES[index].start_date && CRO_POLICIES[index].end_date && CRO_POLICIES[index].end_date < now_datetime) { return false; } } if (CRO_POLICIES[index].target_window_type == 1) { KASIKA.target_window_type = '_blank'; } else { KASIKA.target_window_type = '_self'; } KASIKA.policy_type = CRO_POLICIES[index].policy_type; // リンク誘導 if (CRO_POLICIES[index].policy_type == 3) { KASIKA.inquiry_url = CRO_POLICIES[index].policy_link; } KASIKA.setCroPolicyActionProperty(cro_policy_id, CRO_POLICIES[index].policy_type); is_match = true; } }); } return is_match; }, setCroPolicyActionProperty: function(cro_policy_id, policy_type) { if (typeof CRO_POLICY_ACTIONS === 'object') { // cro_policy_action 検索 Object.keys(CRO_POLICY_ACTIONS).some(function(key, index){ if (key != index) { return false; } if (CRO_POLICY_ACTIONS[index].cro_policy_id == cro_policy_id) { // cro_policy_action KASIKA.action_color = CRO_POLICY_ACTIONS[index].action_color; KASIKA.default_action_header = CRO_POLICY_ACTIONS[index].action_header; KASIKA.is_show_session = CRO_POLICY_ACTIONS[index].is_show_session; KASIKA.company_id = CRO_POLICY_ACTIONS[index].company_id; KASIKA.show_session_date = CRO_POLICY_ACTIONS[index].show_session_date; KASIKA.is_use_dynamic_image = CRO_POLICY_ACTIONS[index].is_use_dynamic_image; KASIKA.is_use_dynamic_name = CRO_POLICY_ACTIONS[index].is_use_dynamic_name; KASIKA.is_use_dynamic_url = CRO_POLICY_ACTIONS[index].is_use_dynamic_url; KASIKA.is_auto_assign_cvtag_user_group_id = CRO_POLICY_ACTIONS[index].is_auto_assign_cvtag_user_group_id; KASIKA.dynamic_name_selector_pattern = CRO_POLICY_ACTIONS[index].dynamic_name_selector_pattern; KASIKA.dynamic_image_selector_pattern = CRO_POLICY_ACTIONS[index].dynamic_image_selector_pattern; KASIKA.dynamic_url_selector_pattern = CRO_POLICY_ACTIONS[index].dynamic_url_selector_pattern; KASIKA.dynamic_page_id_pattern = CRO_POLICY_ACTIONS[index].dynamic_page_id_pattern; KASIKA.popup_height = 'auto'; KASIKA.cro_policy_action_id = CRO_POLICY_ACTIONS[index].cro_action_policy_id; KASIKA.action_button_text = CRO_POLICY_ACTIONS[index].action_button_text; KASIKA.action_image_url = CRO_POLICY_ACTIONS[index].action_image_url; KASIKA.action_link = CRO_POLICY_ACTIONS[index].action_link; KASIKA.action_timing = CRO_POLICY_ACTIONS[index].action_timing; KASIKA.action_timing_setting = CRO_POLICY_ACTIONS[index].action_timing_setting; KASIKA.action_type = CRO_POLICY_ACTIONS[index].action_type; KASIKA.img_width = CRO_POLICY_ACTIONS[index].img_width; if (CRO_POLICY_ACTIONS[index].action_content) { KASIKA.action_content = CRO_POLICY_ACTIONS[index].action_content.replace(/\r?\n/g, '
'); } else { KASIKA.action_content = ""; } // お問い合わせURL作成 if (policy_type == 1 || policy_type == 2) { KASIKA.inquiry_url = KASIKA.inquiry_url + CRO_POLICY_ACTIONS[index].cro_action_policy_id; } if (CRO_POLICY_ACTIONS[index].display_position == 1) { KASIKA.display_position = 'right'; } else { KASIKA.display_position = 'left'; } if (CRO_POLICY_ACTIONS[index].display_position_sp == 2) { KASIKA.display_position_sp = 'top'; } return true; } }) } }, isDisplayFromCustomer : function(cro_policy_id){ var now = Date.now() var query = 'cpid='+cro_policy_id+'&date='+now+'&cc='+cookie_sync; if( this.coco_cid || _visitor_id ){ if( this.coco_cid ){ //ToDo:consolelogは最終的に削除するよ console.log('Confirm display setting with coco_cid :',this.coco_cid); query += '&cid='+this.coco_cid+'&vid='+_visitor_id; }else if( _visitor_id ){ //ToDo:consolelogは最終的に削除するよ console.log('Confirm display setting with visitor_id :',_visitor_id); query += '&vid='+_visitor_id; } }else{ //ToDo:consolelogは最終的に削除するよ console.log('visitor_id & coco_cid is not exist'); } var xmlHttp; xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", "https://panda.kasika.io/cro_display_check.php?"+query, false); xmlHttp.send(null); var res = JSON.parse(xmlHttp.responseText); console.log(res); if( res && res.status == 1 ){ return true; } return false; }, loadKasikaLibrary: function() { KASIKA.loadScript(JQUERY_URL, function() { KASIKA.loadLibrary(TPL_URL); KASIKA.loadLibrary(LIB_URL); }); }, loadScript: function(url, callback) { var script = document.createElement('script'); script.async = true; script.src = url; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); script.onload = script.onreadystatechange = function() { var rdyState = script.readyState; if (!rdyState || /complete|loaded/.test(script.readyState)) { callback(); script.onload = null; script.onreadystatechange = null; } }; }, loadLibrary: function (url, integrity) { var script = document.createElement('script'), entry = document.getElementsByTagName('script')[0]; script.async = true; script.src = url; if (integrity) { script.integrity = integrity; script.crossOrigin = 'anonymous' } entry.parentNode.insertBefore(script, entry); }, loadStyleSheet: function (url) { var link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = url; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(link, entry); }, version: function (a,op,b) { a = a.split('.'); b = b.split('.'); var ia,ib; var limit = Math.max(a.length,b.length); while(limit--) { ia = parseInt(a.shift() || 0); ib = parseInt(b.shift() || 0); if(ia != ib) break; } return eval([ia,op,ib].join(' ')); } } })();